<?php namespace Home\Controller; 

use Hdphp\Controller\Controller;

//内容页控制器
class ContentController extends Controller{
	
	
    // 内容页首页
    public function index(){
//  	实例化内容详情表
       $gdetailModel = new \Common\Model\Gdetail;
       $gid= Q('get.gid',0,'intval');
	   
	   $gdetail = $gdetailModel->where("good_gid={$gid}")->get();
	   $gdetail[0]['pic']=explode(',',  $gdetail[0]['pic']);
	   // p($gdetail);
	   
	   View::with('gdetail',$gdetail);
		 
		// 实例化商品表
	   $goodModel = new \Common\Model\Good;
	   $goodData = $goodModel->where("gid={$gid}")->find();
	   // p($goodData);

	   View::with('goodData',$goodData);



	   $goodsAttr=new \Common\Model\Gnature;
		//关联商品属性表和类型属性表,获得规格的数据
		$goodsData=$goodsAttr->join('typeattr','typeattr_taid','=','taid')->where("good_gid={$gid} && class=0")->get();
		//获得颜色尺码
		// p($goodsData);

		$tepy=array();
		foreach ($goodsData as $k => $v) {
			$tepy[$v['taname']][]=$v;
		}
         // p($tepy);
		View::with('tepy',$tepy);
		//获得属性的数据
		$goodsattrData=$goodsAttr->join('typeattr','typeattr_taid','=','taid')->where("good_gid={$gid} && class=1")->get();
		View::with('goodsattrData',$goodsattrData);
	   
		
		
		
        View::make();
    }

   
    
}